#ifndef INIT_H
#define INIT_H



#include <cstddef>
#include <map>



template< typename T >
class array2d
{

public:

	array2d( unsigned int size_x, unsigned int size_y )
	{
		arr = new T[ size_x * size_y ];
		s_x = size_x;
		s_y = size_y;
	};

	array2d( const array2d< T >& a2d )
	{
		arr = new T[ a2d.s_x * a2d.s_y ];
		s_x = a2d.s_x;
		s_y = a2d.s_y;
		for ( unsigned int i = 0; i < ( s_x * s_y ); ++i )
			arr[ i ] = a2d.get( i );
	};

	~array2d()
	{
		delete [] arr;
	};

	T get( unsigned int x, unsigned int y )
	{
		return arr[ x + ( y * s_x ) ];
	};

	T get( unsigned int n ) const
	{
		return arr[ n ];
	};


	bool set( T o, unsigned int x, unsigned int y )
	{
		if ( ( x < s_x ) && ( y < s_y ) )
		{
			arr[ x + ( y * s_x ) ] = o;
			return true;
		}
		return false;
	};


private:

	T* arr;
	unsigned int s_x;
	unsigned int s_y;

};



class unit_types
{

public:

	static unit_types* get_instance();

	bool load_types( const char* file );

	int x;

private:

	unit_types( int _x ): x( _x ) {};
	unit_types( const unit_types& );
	unit_types& operator=( const unit_types& x );

	bool parse_unit_line( std::string ul );

};



class parameters
{

public:

	static parameters* get_instance();

	bool load_parameters( const char* file );


	std::map< std::string, unsigned int > game_parameters;
	std::map< std::string, unsigned int > gui_parameters;
	std::map< std::string, std::map< std::string, double > > ai_parameters;


	int x;

private:

	parameters( int _x ): x( _x ) {};
	parameters( const parameters& );
	parameters& operator=( const parameters& x );

	bool parse_param_line( std::string pl );
	bool check_parameters();
	bool check_values();

};



#endif